﻿#region Copyright © 2013 Paul Miller (Millz)
// All rights are reserved. Reproduction or transmission in whole or in part,
// any form or by any means, electronic, mechanical or otherwise, is prohibited
// without the prior written consent of the copyright owner.
// 
// Filename: Log.cs
// Date:     23/09/2013
// Author:   Paul Miller (Millz)
#endregion

using System;
using System.Windows.Media;
using Styx;
using Styx.Common;
using Styx.CommonBot;

namespace Insanity.Helpers
{
        static class Log
        {
            private static string _lastMessage = "";

            public static void Info(string message, params object[] args)
            {
                try
                {
                    string formatted = TreeRoot.IsRunning
                        ? string.Format("[Insanity] [HP: " + StyxWoW.Me.HealthPercent.ToString("##.#") + "] [Mana: " + StyxWoW.Me.ManaPercent.ToString("##.#") + "] " + message, args)
                        : string.Format("[Insanity] " + message, args);

                    if (_lastMessage == formatted) return;
                    _lastMessage = formatted;

                    Logging.Write(Colors.White, formatted);
                }
                catch (Exception ex)
                {
                    Logging.Write(Colors.Red, "Exception thrown at Log.Info(): {0}", ex);
                }
                
            }

            public static void Debug(string message, params object[] args)
            {
                try
                {
                    Logging.Write(LogLevel.Diagnostic, Colors.Aquamarine, "[Insanity - Debug] {0}", string.Format(message, args));
                }
                catch (Exception ex)
                {
                    Logging.Write(Colors.Red, "Exception thrown at Log.Debug(): {0}", ex);
                }

                
            }
            
            public static void Fail(string message, params object[] args)
            {
                try
                {
                    Logging.Write(LogLevel.Diagnostic, Colors.Crimson, "[Insanity - Fail] {0}", string.Format(message, args));
                }
                catch (Exception ex)
                {
                    Logging.Write(Colors.Red, "Exception thrown at Log.Fail(): {0}", ex);
                }
                
            }

            public static void Orange(string message, params object[] args)
            {
                try
                {
                    Logging.Write(Colors.OrangeRed, "[Insanity] {0}", string.Format(message, args));
                }
                catch (Exception ex)
                {
                    Logging.Write(Colors.Red, "Exception thrown at Log.Orange(): {0}", ex);
                }
                
            }

            public static void Red(string message, params object[] args)
            {
                try
                {
                    Logging.Write(Colors.Red, "[Insanity] {0}", string.Format(message, args));
                }
                catch (Exception ex)
                {
                    Logging.Write(Colors.Red, "Exception thrown at Log.Orange(): {0}", ex);
                }

            }

        }
}
